package com.chenwang.measure.ui.adapter;

import android.bluetooth.BluetoothDevice;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenwang.measure.R;

import java.util.List;

/**
 * @松 on 2019/7/19 11:46
 * 搜索蓝牙设备适配器
 */
public class BluetoothScanAdapter extends BaseQuickAdapter<BluetoothDevice, BaseViewHolder> {

    public BluetoothScanAdapter(@Nullable List<BluetoothDevice> data) {
        super(R.layout.item_bluetooth_activity, data);

    }

    @Override
    protected void convert(BaseViewHolder helper, BluetoothDevice item) {
        helper.setText(R.id.tv_name,item.getName() );
          // BluetoothDevice.BOND_BONDED 已配对 12
        // BluetoothDevice.BOND_BONDING 正在配对 11
         //  BluetoothDevice.BOND_NONE 未配对 10

           helper.setText(R.id.statu, item.getBondState() == 10 ? "未配对" : "已配对");


    }
    public void clear() {
       if (mData!= null){
           if (mData.size()> 0){
                mData.clear();
                notifyDataSetChanged();
           }
       }

    }

}
